﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Logic
{
    
    //This class defines an actors overall traits, such as armor, health or attack range
    class Traits
    {
        //Maximum melee attack range
        public int AutoAttackRange { get; set; }

        //Range value deciding how close the enemy actor needs to be until the actor goes for melee attacks
        private int _autoAttackAgressionRange;
        public int AutoAttackAgressionRange {
            get { return _autoAttackAgressionRange; }
            set
            {
                if (value < 0)
                {
                    return;
                }
                _autoAttackAgressionRange = value >= AutoAttackRange ? AutoAttackRange : value;
            }
        }

        private int _attackDamage;
        public int AttackDamage 
        { 
            get { return _attackDamage; }
            set
            {
                if(_attackDamage < 0 )
                {
                    _attackDamage = 0;
                    return;
                }
                _attackDamage = value;
            }
        }

        //Health of the actor, absolute value
        private int _health;
        public int Health
        {
            get { return _health; }
            set
            {
                if (value < 0)
                {
                    _health = 0;
                    return;
                }
                _health = value;
            }
        }

        //Max Health of the actor, absolute value
        private int _maxhealth;
        public int MaxHealth
        {
            get { return _maxhealth; }
            set
            {
                if (value < 0)
                {
                    _maxhealth = 0;
                    return;
                }
                _maxhealth = value;
            }
        }

        //value determining when the health status is considered critical, percentage 0-100
        private int _criticalHealthPercentage;
        public int CriticalHealthPercentage
        {
            get { return _criticalHealthPercentage; }
            set
            {
                if (value < 0)
                {
                    _criticalHealthPercentage = 0;
                    return;
                }

                if (value > 100)
                {
                    _criticalHealthPercentage = 100;
                    return;
                }

                _criticalHealthPercentage = value;
            }
        }

        //energy pool of the actor
        private int _energy;
        public int Energy
        {
            get { return _energy; }
            set
            {
                if (value < 0)
                {
                    _energy = 0;
                    return;
                }
                _energy = value;
            }
        }
        
        //armor value of the actor
        //armor governs physical damage reduction
        private int _armor;
        public int Armor
        {
            get { return _armor; }
            set
            {
                if (value < 0)
                {
                    _armor = 0;
                    return;
                }
                _armor = value;
            }
        }

        private int _magicResist;
        public int MagicResistance
        {
            get { return _magicResist; }
            set
            {
                if (value < 0)
                {
                    _magicResist = 0;
                    return;
                }
                _magicResist = value;
            }
        }

        //Attack speed of the actor measured in attacks per second
        private double _attackspeed;
        public double AttackSpeed
        {
            get { return _attackspeed; }
            set
            {
                if (value < 0.0)
                {
                    _attackspeed = 0.0;
                    return;
                }

                //ASPD cap is 2.5 attacks/sec currently
                if (value > 2.5)
                {
                    _attackspeed = 0.0;
                    return;
                }

                _attackspeed = value;
            }
        }
    }
}
